#include <fstream>
using namespace std;
#include <misc/argvutils.h>

#include "axes.h"

void print_usage(char* argv0) {
  cerr << argv0 << " -- dumps axes file." << endl;
  cerr << "Usage: " << argv0 << " --axes-fn=<axes-filename>" << endl;
  exit(3);
}

int main(int argc, char** argv)
{
  try {
  DictVector<string, string> args = argv_utils::parse_to_dict(argc, argv);
  if (args.size() == 0 || args.has_key("--help")) {
    print_usage(argv[0]);
  }

  string axes_fn = args.get("--axes-fn");
  Axes axes;
  ifstream in(axes_fn.c_str());
  axes.load(in);
  axes.print(cout);
  for (size_t i = 0; i < axes.get_n_dim(); i++) {
    axes.get_at(i)->print(cout);
    cout << endl << "-------------------" << endl;
  }
  cout << endl;
  } catch (Error& e) {
    cerr << "Error caught: " << e.msg() << endl;
  }
}
